package com.wanxi.springboot.team.manage.system.controller;


import com.wanxi.springboot.team.manage.system.api.CommonResult;
import com.wanxi.springboot.team.manage.system.generator.WordGenerate;
import com.wanxi.springboot.team.manage.system.model.DailySummary;
import com.wanxi.springboot.team.manage.system.service.DailySummaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 蒋帆
 * @since 2020-12-21
 */
@RestController
@RequestMapping("/summary")
public class DailySummaryController {

    @Autowired
    DailySummaryService dailySummaryService;

    @PreAuthorize("hasAnyAuthority('summary:add')")
    @PostMapping("/addSummary")
    public CommonResult addSummary(@RequestBody DailySummary dailySummary){
        return dailySummaryService.addSummary(dailySummary);
    }

    @PreAuthorize("hasAnyAuthority('summary:edit')")
    @PostMapping("/editSummary")
    public CommonResult editSummary(@RequestBody DailySummary dailySummary){
        return dailySummaryService.editSummary(dailySummary);
    }

    @PreAuthorize("hasAnyAuthority('summary:read')")
    @PostMapping("/readSummary")
    public CommonResult readSummary(@RequestParam Integer id){
        return dailySummaryService.readSummary(id);
    }

    @PreAuthorize("hasAnyAuthority('summary:get:all')")
    @GetMapping("/getDailySummary")
    public CommonResult getDailySummary(@RequestParam Map map){
        return dailySummaryService.getDailySummary(map);
    }

    @PreAuthorize("hasAnyAuthority('summary:get:self')")
    @GetMapping("/getSelfDailySummary")
    public CommonResult getSelfDailySummary(@RequestParam Map map){
        return dailySummaryService.getSelfDailySummary(map);
    }

    @PreAuthorize("hasAnyAuthority('summary:export')")
    @PostMapping("/exportSummary")
    public CommonResult exportSummary(@RequestParam Map map, HttpServletResponse response){
        return dailySummaryService.exportSummary(map,response);
    }

    @PreAuthorize("hasAnyAuthority('summary:export:batch')")
    @PostMapping("/batchExportSummary")
    public CommonResult batchExportSummary(@RequestParam String list, HttpServletResponse response){
        return dailySummaryService.batchExportSummary(list,response);
    }
}
